<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
//          比如我要过滤 "SM"
var str = 'asdasdSMasdasdasdSMsdasdasdSMsadasd'

var res = str.split('SM').join('**')

console.log(res);


// // 需要结果
// // asdasd**asdasdasd**sdasdasd**

     
    </script>
</body>
</html>